<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->params['static'].'assets/js/bootbox.min.js',2); ?>
<div class="page-header">
							<h1>
							综合奖学金报表
							</h1>
</div>
<div class="row">
<div class="col-xs-12">
<div class="row">
<div class="col-xs-12">
										<div class="widget-box">
											<div class="widget-header widget-header-small">
												<h5 class="lighter">查询</h5>
											</div>

											<div class="widget-body">
												<div class="widget-main">
													<?php $this->renderPartial("_searchform",array('classRooms'=>$classRooms,'major'=>$major)); ?>
												</div>
											</div>
										</div>
										
</div>
</div>
<div class="hr hr-18 dotted hr-double"></div>
<div class="row">

		<div class="col-xs-12">
		    <div class="widget-box">
											<div class="widget-header widget-header-small">
												<h5>共检索出：<?php echo $total; ?> 条数据</h5>
											</div>

											<div class="widget-body">
												<div class="widget-main">
											<div class="table-responsive">
										<div class="table-responsive">
											<table id="sample-table-1" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
													
													   <th>姓名</th>
														<th>学号</th>
														<th>
														电话
														</th>
														
														<th>
														年级
														</th>
														<th>
														专业
														</th>
														<th>
														班级
														</th>
														
														
														<th>
														<i class="icon-wrench bigger-110 hidden-480"></i>
														操作
														</th>
													</tr>
												</thead>

												<tbody>
												
												<?php
											    foreach($stus as $s){
													  $realName = $s->stuinfo?$s->stuinfo->realName:'未添加';
													  $classRoom = $s->stuinfo?$s->stuinfo->classRoom:'未添加';
													  $phoneNum = $s->stuinfo?$s->stuinfo->phoneNum:'未添加';
													  $grade = $s->stuinfo?$s->stuinfo->grade:'未添加';
													  $stumajor = $s->stuinfo?$s->stuinfo->major:'未添加';
												echo'	
												<tr>
												
												<td>'.$realName.'</td>
												<td>'.$s->username.'</td>
												<td>'.$phoneNum.'</td>
												<td>'.$grade.'</td>
												<td>'.$stumajor.'</td>
												<td>'.$classRoom.'</td>
												
												
												
												<td>
															<div>
												                <a target="_blank" href="'.Yii::app()->createUrl("scholarship/onestureport",array('uId'=>$s->uId)).'">
																<button  class="btn btn-xs btn-warning" data-rel="tooltip" data-original-title="详情">
																	<i class="icon-bar-chart bigger-120"></i>
																</button>
																</a>
																
																
															</div>

														</td>
											    </tr>';
												}
                                               ?>													
											    </tbody>
											
											</table>
									       
											
						
							</div><!-- /.table-responsive -->
							<div class="col-xs-12" style="text-align:center">
										     <?php 
											 $this->widget('CLinkPager',array( 
													'htmlOptions'=>array('class'=>'pagination'),
													'cssFile'=>false,
													'header'=>'',    
													'firstPageLabel' => '首页',    
													'lastPageLabel' => '末页',    
													'prevPageLabel' => '上一页',    
													'nextPageLabel' => '下一页',    
													'pages' => $pages,    
													'maxButtonCount'=>13    
												)    
											);    
												
										?>
						</div>
						
					</div>
			      </div>
			</div>
		</div>
	</div>
</div>
<div class="row">
   <div class="col-sm-2">
			<form id = "export-word" target="_blank" method="get" id="export2word" action="<?php echo Yii::app()->createUrl('scholarship/exportword'); ?>">
			  <div name="tempPosition"></div>
			  <button type="submit" class="btn btn-info" >
				<i class="icon-share"></i>
					导出为 WORD									
			  </button>
			</form>
   </div>
    <div class="col-sm-2">
				<form id="export-form" method="get" action="<?php echo Yii::app()->createUrl('scholarship/exportexcel');?>" target="_blank" style="display:inline;">
								<?php
								   $request = Yii::app()->request;
								   echo '<input type="hidden" value="'.$request->getParam('grade').'" name="grade">';
								   echo '<input type="hidden" value="'.$request->getParam('major').'" name="major">';
								   echo '<input type="hidden" value="'.$request->getParam('classRoom').'" name="classRoom">';
								   echo '<input type="hidden" value="'.$request->getParam('stuNum').'" name="stuNum">';
								?>
								 <button class="btn btn-success">
									<i class="icon-share-alt" type="button" id="export-button"></i>
										导出为 EXCEL										
								  </button>
				</form>
  
   </div>
</div>
<script type="text/javascript">

			jQuery(function($) {
				
			      $('#export-form').on('click',function(){
					 
					bootbox.dialog({
							title: "选择学期",
							message: '<div class="row">  ' +
								'<div class="col-md-12"> ' +
								'<form class="form-horizontal"> ' +
								'<div class="form-group"> ' +
								'<label class="col-md-4 control-label" for="awesomeness">学期</label> ' +
								'<div class="col-md-4">' +
								'<div class="col-sm-12">' +
									'<select class="form-control" id="export-excel-term" name="term">'+
										'<option value="term_1">第一学期</option>'+
										'<option value="term_2">第二学期</option>'+
										'<option value="term_3">第三学期</option>'+
										'<option value="term_4">第四学期</option>'+
										'<option value="term_5">第五学期</option>'+
									    '<option value="term_6">第六学期</option>'+
										'<option value="term_7">第七学期</option>'+
										'<option value="term_8">第八学期</option>'+
									'</select>'+
							   '</div>'+
							   '</div> </div>' +
							   '</form> </div>  </div>',
							buttons: {
								success: {
									label: "提交",
									className: "btn-success",
									callback: function () {
										var form = $('#export-form');
										var term = '<input type="hidden" name="term" value="'+$('#export-excel-term').val()+'">';
										$(form).children('[name="stuNum"]').after(term);
										$(form).submit();
										return true;
									}
								}
							}
						}
					);
								 
					 
					 return false; 
				  });
			
				
			});
			$('#export-word').on('click',function(){
				
				bootbox.dialog({
							title: "选择专业和班级",
							message: '<div class="row">  ' +
								'<div class="col-md-12"> ' +
								'<form class="form-horizontal"> ' +
								'<div class="form-group"> ' +
								'<label class="col-md-2 control-label" for="awesomeness">专业</label> ' +
								'<div class="col-md-10">' +
								'<div class="col-sm-12">' +
									'<select class="form-control" id="export-word-major" name="major">'+
										<?php
										
										  foreach($major as $m){
												echo '\'<option value="'.$m->name.'" >'.$m->name.'</option>\'+';
																		   
											}
										?>
									'</select>'+
							   '</div>'+
							   '</div> </div>' +
							   '<div class="form-group"> ' +
								'<label class="col-md-2 control-label" for="awesomeness">班级</label> ' +
								'<div class="col-md-10">' +
								'<div class="col-sm-12">' +
									'<select class="form-control" id="export-word-classRoom" name="classRoom">'+
										<?php
										  foreach($classRooms as $c){
												echo '\'<option value="'.$c->name.'" >'.$c->name.'</option>\'+';
																		   
											}
										?>
									'</select>'+
							   '</div>'+
							   '</div> </div>' +
							    '<div class="form-group"> ' +
								'<label class="col-md-2 control-label" for="awesomeness">年级</label> ' +
								'<div class="col-md-10">' +
								'<div class="col-sm-12">' +
									'<select class="form-control" id="export-word-grade" name="grade">'+
										<?php
										   $currentYear = date('Y');
										   $currentYear = (int)$currentYear - 10;
										   for($i = 10;$i>=0;$i--){
											  
											   echo '\'<option value="'.$currentYear.'">'.$currentYear++.'</option>\'+';
											   
										   }
										?>
									'</select>'+
							   '</div>'+
							   '</div> </div>' +
							   '</form> </div>  </div>',
							buttons: {
								success: {
									label: "提交",
									className: "btn-success",
									callback: function () {
										$('.tempAdd').remove();
										var form = $('#export-word');
										var major = '<input class="tempAdd" type="hidden" name="major" value="'+$('#export-word-major').val()+'">';
										var classRoom = '<input class="tempAdd" type="hidden" name="classRoom" value="'+$('#export-word-classRoom').val()+'">';
										var grade = '<input class="tempAdd" type="hidden" name="grade" value="'+$('#export-word-grade').val()+'">';
										$(form).children('[name="tempPosition"]').after(major);
										$(form).children('[name="tempPosition"]').after(classRoom);
										$(form).children('[name="tempPosition"]').after(grade);
										$(form).submit();
										return true;
									}
								}
							}
						}
					);
								 
					return false;
			});
		
</script>